using System;
using System.Collections.Generic;
using System.Text;
using Objects;

namespace DAL
{
    public class DALDanhSachKhachHang
    {
        public List<DanhSachKhachHang> GetAllItem()
        {
            List<DanhSachKhachHang> ListDanhSachKhachHang = new List<DanhSachKhachHang>();

            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] {};
            string[] vname = new string[] {};
            System.Data.DataSet ds = acc.CommandSelect("DanhSachKhachHang_GetAllItem", sname, vname);

            DanhSachKhachHang Item = new DanhSachKhachHang();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                System.Data.DataRow dr = ds.Tables[0].Rows[i];
                ListDanhSachKhachHang.Add((Item.Populate(dr)));
            }
            return ListDanhSachKhachHang;
        }

        public List<DanhSachKhachHang> SearchCustomer(String TenKhachHang, String CMND, int TrangThaiDuyet ,String ngayDangky)
        {
            List<DanhSachKhachHang> ListDanhSachKhachHang = new List<DanhSachKhachHang>();

            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@TenKhachHang","@CMND","@TrangThaiDuyet","@NgayDangKy" };
            string[] vname = new string[] { TenKhachHang.ToString(),CMND.ToString(),TrangThaiDuyet.ToString(),ngayDangky.ToString()};
            System.Data.DataSet ds = acc.CommandSelect("DanhSachKhachHang_Search", sname, vname);

            DanhSachKhachHang Item = new DanhSachKhachHang();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                System.Data.DataRow dr = ds.Tables[0].Rows[i];
                ListDanhSachKhachHang.Add((Item.Populate(dr)));
            }
            return ListDanhSachKhachHang;
        }
    }
}
